package com.example.musicplayer.util

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

class SpaceItemDecoration(private val space: Int) : RecyclerView.ItemDecoration() {

    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        outRect.bottom = space // 在每个项的底部添加间距
        if (parent.getChildAdapterPosition(view) == 0) {
            outRect.top = space // 在第一个项的顶部也添加间距
        }
    }
}